
/*public class Solution {
    public ListNode removeElements(ListNode head, int val) {
        if(head==null){
            return head;
        }
        ListNode prev = head;
        ListNode cur = head.next;
        while(cur!=null){
            if(cur.val==val){
                prev.next=cur.next;
                cur=cur.next;
            }else{
                prev=cur;
                cur=cur.next;
            }
        }
        if(head.val==val){
            head=head.next;
        }
        return head;
    }
}*/

/*
class Solution {
    public ListNode reverseList(ListNode head) {
        if(head == null){
            return head;
        }
        ListNode cur = head.next;
        head.next = null;
        while(cur != null){
            ListNode curN = cur.next;
            cur.next = head;
            head = cur;
            cur = curN;
        }
        return head;
    }
}
*/


/*class Solution {
    public ListNode middleNode(ListNode head) {
        if(head == null){
            return head;
        }
        ListNode fast = head;
        ListNode slow = head;
        while(fast!=null && fast.next!=null){
            fast = fast.next.next;
            slow=slow.next;
        }
        return slow;
    }
}*/


/*class Solution {
    public int kthToLast(ListNode head, int k) {
        if (head == null) return -1;
        if(k<=0){
            return -1;
        }
        ListNode fast = head;
        ListNode slow = head;
        int count =0;
        while(count != k-1){
            fast = fast.next;
            if(fast == null){
                return -1;
            }
            count++;
        }

        while(fast.next!= null){
            fast = fast.next;
            slow = slow.next;
        }
        return slow.val;
    }
}*/
